package cn.net.cfss.fgbp.api.console.inte;

import cn.net.cfss.fgbp.api.console.constant.Constants;
import cn.net.cfss.fgbp.api.console.dto.SysUserDto;
import cn.net.cfss.fgbp.api.console.dto.SysUserRoleDto;
import cn.net.cfss.fgbp.api.console.vo.SysUserDetailVo;
import cn.net.cfss.fgbp.api.console.vo.SysUserLoginVo;
import cn.net.cfss.fgbp.api.console.vo.SysUserVo;
import cn.net.cfss.fgbp.base.page.PageData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name = Constants.SPI_SERVER_NAME)
@RequestMapping("user")
public interface ISysUserService {

    /**
     * 根据用户名统计
     *
     * @param username
     * @return
     */
    @RequestMapping(value = "/countByUsername", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public Long countByUsername(@RequestBody String username);

    /**
     * 新增用户
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public SysUserDto addUserRole(@RequestBody SysUserVo sysUserVo);

    /**
     * 修改用户
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/edit", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public SysUserDto editUserRole(@RequestBody SysUserVo sysUserVo);

    /**
     * 锁定用户
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/lock/{userId}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public void lockUser(@PathVariable(value = "userId") Long userId);

    /**
     * 解锁用户
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/unlock/{userId}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public void unlockUser(@PathVariable(value = "userId") Long userId);

    /**
     * 修改用户密码
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/update/pwd", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public void updatePwd(@RequestBody SysUserVo sysUserVo);

    /**
     * 设置用户角色
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/set/role", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public void setRole(@RequestBody SysUserVo sysUserVo);

    /**
     * 设置用户业务类型
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/set/busiType", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public void setBusiType(@RequestBody SysUserVo sysUserVo);

    /**
     * 根据ID删除用户
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/delete/{userId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public void delete(@PathVariable(value = "userId") Long userId);

    /**
     * 根据ID数组批量删除用户
     *
     * @param userIds
     * @return
     */
    @RequestMapping(value = "/deleteBatch", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public int deleteBatchByLogic(@RequestBody List<Long> userIds);

    /**
     * 根据ID查询用户数据
     *
     * @param userId
     * @return
     */
    @RequestMapping(value = "/get/{userId}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public SysUserVo get(@PathVariable(value = "userId") Long userId);

    /**
     * 根据ID查询用户数据
     *
     * @param username
     * @return
     */
    @RequestMapping(value = "/query/{username}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public SysUserDto queryByUsername(@PathVariable(value = "username") String username);

    /**
     * 根据条件查询用户列表
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/query/list", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public List<SysUserDto> queryList(@RequestBody SysUserVo sysUserVo);

    /**
     * 分页查询用户列表数据
     *
     * @param page
     * @return
     */
    @RequestMapping(value = "/query/page", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public PageData<SysUserVo> queryByPage(@RequestBody PageData<SysUserVo> page);

    @RequestMapping(value = "/uniquenessCheck", method = RequestMethod.GET)
    public boolean uniquenessCheck(@RequestParam("username") String username, @RequestParam(value = "id", required = false) Long id);

    /**
     * 用户登录
     *
     * @return
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public SysUserLoginVo login(@RequestParam("username") String username, @RequestParam(value = "password") String password, @RequestParam(value = "ip", required = false) String ip);

    @RequestMapping(value = "/getPermissions", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public SysUserDetailVo getPermissions(@RequestBody String userId);

    /**
     * 用户唯一检验（邮箱，手机号码）
     *
     * @param sysUserVo
     * @return
     */
    @RequestMapping(value = "/uniqueUser", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public List<SysUserDto> uniqueUser(@RequestBody SysUserVo sysUserVo);

    @RequestMapping(value = "/query/user/role", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public List<SysUserRoleDto> queryUserRole(@RequestBody SysUserRoleDto userRoleDto);

    @RequestMapping(value = "/checkUserRole", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public Boolean checkUserRole(@RequestParam("roleCode") String roleCode, @RequestParam(value = "id") Long userId);

    @RequestMapping(value = "/test", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    int test();

    @RequestMapping(value = "/getRoleCodeByUid", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public List<String> getRoleCodeByUid(@RequestBody Long userId);
}